rm(list = ls())

library(tidyverse)

data <- openxlsx::read.xlsx("data/PV_lanhua.xlsx")
xlabel <- data %>% names() %>% .[-1]
ylabel <- rev(data$X1)

df <- data %>% 
  pivot_longer(cols = 2:73,names_to = "VOC",values_to = "value") %>% 
  mutate(plant = X1)

df %>% 
  mutate(value = as.factor(value)) %>%
  ggplot(aes(y=factor(plant, levels = ylabel),x=factor(VOC, levels = xlabel))) +
  geom_tile(aes(fill=value),color="black")+
  coord_equal() +
  scale_fill_manual(values = c("white","black")) + 
  scale_x_discrete(labels=xlabel)+
  scale_y_discrete(labels=ylabel)+
  theme(legend.position =  "none",
        axis.text.x=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.x = element_blank(),
        axis.ticks.y = element_blank(),) +
  xlab("VOC")+
  ylab("Plant")
  # coord_flip()

